package domain;

import java.util.Iterator;
import java.util.List;

import data.JDBCFileDAO;

public class FileStore {

    private static FileStore fs;

    private List<File> files;

    public static synchronized FileStore getInstance() {
        if (fs == null)
            fs = new FileStore();
        return fs;
    }

    private FileStore() {
        files = (new JDBCFileDAO()).selectAllFiles();
    }

    public List<File> getFiles() {
        return files;
    }

    public File getFile(Integer FOID) {
        File result = null;
        for (Iterator<File> iter = files.iterator(); iter.hasNext();) {
            File f = (File) iter.next();
            if (f.getId().compareTo(FOID) == 0) {
                result = f;
            }
        }
        return result;
    }
}